<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <title>IconFont</title>
    <link rel="stylesheet" href="/static/css/my/common.css">
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <link rel="stylesheet" href="/static/lib/layui/css/layui.css">

</head>
<body>
<div>
    <div class="layui-container">
        <div class="layui-row">
            <div class="layui-col-md3">
                <div id="test1"></div>
            </div>
            <div class="layui-col-md9">
                <form class="layui-form" action="/department/save" method="post">
                    <div class="layui-form-item">
                        <label class="layui-form-label">部门名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">所属部门</label>
                        <div class="layui-input-block">
                            <select name="parent_id" lay-verify="required">
                                <option th:value="${department.id}" th:text="${department.name}"></option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">部门职能</label>
                        <div class="layui-input-block">
                            <textarea name="remark" placeholder="请输入内容" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" type="submit" lay-submit lay-filter="formDemo">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <script type="application/javascript" src="/static/lib/layui/layui.js"></script>
</div>
<script  type="text/javascript" th:inline="javascript">
    var treeList = [[${departmentTreeList}]]
    layui.use(['tree','jquery'], function () {
        var tree = layui.tree;
        //渲染
        var inst1 = tree.render({
            elem: '#test1'  //绑定元素
            , data: treeList
            ,click:function (obj) {
                window.open('/department/queryParent?id='+obj.data.id+"&time=" + Math.random(),'_self')
                //$('iframe').attr('src','/department/queryParent?id='+obj.data.id+"&time=" + Math.random());
            }
        });
    });
</script>
</body>
</html>
